//
//  Common.h
//  CityHunter
//
//  Updated by xcq on 2014-10-21.
//  Copyright (c) 2014年 CieNet. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CLMarcoDefine.h"
#import "JGActionSheet.h"
#import "ConfigDefine.h"



#ifndef GET_VIEW_RIGHT
#define GET_VIEW_RIGHT(view) (view.frame.origin.x + view.frame.size.width)
#endif
#ifndef GET_VIEW_BOTTOM
#define GET_VIEW_BOTTOM(view) (view.frame.origin.y + view.frame.size.height)
#endif

#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

//忽略     [_target performSelector:_action withObject:self]
//方法的警告
#define SuppressPerformSelectorLeakWarning(Stuff) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
Stuff; \
_Pragma("clang diagnostic pop") \
} while (0)
@interface Common : NSObject

//判断当前时间是白天还是晚上,YES:白天 NO:晚上
+ (BOOL)isBetweenFromHour:(NSInteger)fromHour toHour:(NSInteger)toHour;


+ (ESystemVer)systemVersion;
//是否安装某个应用
+ (BOOL)judgeAppInstall:(NSString *)urlStr;
//打开第三方应用
+ (void)openThirdParty:(NSString *)urlStr;


+ (UIImage *)resizeImage:(UIImage *)imgName;

//获取当前的视图控制器
+ (UIViewController*)viewController;

//设置输入控件UITextField和UITextView的border
+ (void)setInputCustomerStyle:(UIView*)input;

//对于网络返回的数据包做一般性的分析，并根据结果发送通知
+ (void)analyseNetworkResponseAndNotify:(id)rspData
                               moduleID:(NSInteger)moduleID
                              funIDSucc:(NSInteger)funIDSucc
                              funIDFail:(NSInteger)funIDFail;
+ (void)analyseNetworkResponseAndNotify:(id)rspData
                               moduleID:(NSInteger)moduleID
                              funIDSucc:(NSInteger)funIDSucc
                              funIDFail:(NSInteger)funIDFail
                                success:(void (^)(NSDictionary *dic))success
                                failure:(void (^)(NSDictionary *dic))failure;

+ (void)loginWithCurrentUser;

+ (NSString *)calDateIntervalFromEndDate:(NSString *)paramEndDate;

+ (NSString*)getLocalStr:(NSString*)key;

+ (void)showLocalAlert:(NSString*)title message:(NSString*)message;
+ (void)showLocalAlert:(NSString *)title message:(NSString *)message delegate:(id<UIAlertViewDelegate>)delegate;

+ (void)showLocalAlert:(NSString*)title message:(NSString*)message andTag:(NSInteger)tag;
+ (void)showLocalAlert:(NSString *)title message:(NSString *)message delegate:(id<UIAlertViewDelegate>)delegate andTag:(NSInteger)tag;

+ (void)showAlert:(NSString*)title message:(NSString*)message;
+ (void)showAlert:(NSString*)title message:(NSString *)message delegate:(id<UIAlertViewDelegate>)delegate andAlert:(NSInteger)tag;

+ (void)showJGActionSheet:(NSString *)title
                  message:(NSString *)message
              cancelTitle:(NSString*)cancelTitle
             buttonTitles:(NSArray *)buttonTitles
              buttonStyle:(JGActionSheetButtonStyle)buttonStyle
                 delegate:(id<JGActionSheetDelegate>)delegate
                      tag:(NSUInteger)tag
               showInView:(UIView *)view;

+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size;

+ (CGSize)fitSizeForText:(NSString*)text font:(UIFont*)font;
+ (CGSize)fitSizeForText:(NSString*)text font:(UIFont*)font maxWidth:(CGFloat)maxWidth;
+ (CGSize)fitSizeForText:(NSString*)text font:(UIFont*)font maxHight:(CGFloat)maxHeight;
+ (CGSize)fitSizeForText:(NSString*)text font:(UIFont*)font maxWidth:(CGFloat)maxWidth maxHight:(CGFloat)maxHeight;

-(NSString *)substringFromHeadNum:(NSUInteger)Num andObj:(NSString *)_self;
    
-(NSString *)substringFromTailNum:(NSUInteger)Num andObj:(NSString *)_self;

- (NSString *)deleteSpaceCharObj:(NSString *)_self;


+ (void)callPhone:(NSString *)phone andControl:(UIView *)View;;

+ (void)printFrame:(CGRect)frame message:(NSString*)msg;

+ (BOOL)isEmptyString:(NSString*)string;

+ (NSString *) md5:(NSString*)string;

+ (void)setUserInfo:(NSDictionary *)dic;

+ (void)setToken:(NSString *)token;

+ (void)setCurrenUserName:(NSString *)name;

+ (void)setPassWord:(NSString *)password;

+ (void)setUserId:(NSString *)userId;

+ (void)setPhoneNum:(NSString *)PhoneNum;

+ (void)setLoginStatus:(BOOL)bol;

+ (void)setCurrenCity:(NSMutableDictionary *)city;

+ (BOOL)currenLoginStatus;

+ (void)setCurrenPhoto:(NSString *)photoData;

+ (void)setCurrenVB:(NSNumber *)vb;

+ (void)setAutoLogin:(BOOL)bol;

+ (BOOL)currenAutoLogin;

+ (BOOL)isBaiDay;

+ (void)setBaiDay;

+ (NSNumber *)currenVB;

+ (NSMutableDictionary *)currenCity;

+ (NSString *)currenPhoto;

+ (NSString*)currentToken;

+ (NSDictionary*)currentUserInfo;

+ (NSString*)currentUserName;

+ (NSString*)currentPassword;

+ (NSString*)currentUserId;

+ (NSString*)currentPhoneNum;

+ (NSString *)userName;

+ (void)setUserName:(NSString *)name;

+ (BOOL)regexString:(NSString*)string match:(NSString*)match;

+ (BOOL)isMobileNumber:(NSString *)string;

+ (BOOL)isUserName:(NSString*)string;

+ (BOOL)isPassword:(NSString*)string;

+ (BOOL)isRealName:(NSString*)string;

+ (BOOL)isIDNumber:(NSString*)string;

+ (BOOL)isValidateEmail:(NSString *)string;
//上传图片
+ (void)upLoadImage:(NSString *)kbaseUrl andFileSuffixRandom:(int)max andFile:(UIImage *)image andSucces:(void (^)(id result))callback andFail:(void (^)(id result))failCallback ;

+ (CGSize)sizeWithContent:(NSString *)content AndFont:(UIFont *)font andSize:(CGSize)size  andLineBreak:(NSLineBreakMode)line;
//根据输入的参数，转换成url的参数字符串
+ (NSString*)URLEncodedStringFromKeyAndValue:(NSString*)key value:(id)value;

//将字典的参数转换成字符串的数组，用以在post请求的url中
+ (NSArray*)queryStringPairsFromKeyAndValue:(NSString*)key value:(id)value;

+ (BOOL)copyResourceToDocumentsFolder:(NSString*)fileName;

+ (NSString*)getResourceFilePath:(NSString*)fileName;

+ (NSString*)getErrorDescription:(NSString*)errorCode;

+(BOOL)isNetWorkReachable:(void (^)(NSInteger status))block;

+ (UIViewController*)viewController:(UIView *)view;

+ (double) folderSizeAtPath:(NSString*) folderPath;
@end
